<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>teacherPage</title>
    <link th:href="@{/webjars/bootstrap/3.4.1/css/bootstrap.css}" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">首页</a>
        </div>
        <div>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/teacherInfo">个人信息</a></li>
                <li><a href="/uploadPage">上传视频</a> </li>
                <li th:text="${session.email}">email</li>
            </ul>
        </div>
    </div>
</nav>
<div th:each="uncheckedCourse:${uncheckedCourses}">
    <div class="col-sm-6 col-md-3">
        <div class="thumbnail">
            <img src="img/uiz7.jpg" th:src="'/img/img'+${uncheckedCourse.getCourseId()}+'.jpg'"
                 alt="通用的占位符缩略图">
            <div class="caption" th:id="${uncheckedCourse.getCourseId()}">
                <h3><a class="video" href="#" th:href="'/video/video'+${uncheckedCourse.getCourseId()}+'.mp4'" th:text="${uncheckedCourse.getCourseName()}">缩略图标签</a></h3>
                <p th:text="${uncheckedCourse.getSpecialty()}">一些示例文本。一些示例文本。</p>
                <button type="button" class="btn btn-primary deleteCourse" value="deleteCourse">删除视频</button>
                <label style="text-align: right">审核中...</label>
            </div>
        </div>
    </div>
</div>
<div th:each="checkedCourse:${checkedCourses}">
    <div class="col-sm-6 col-md-3">
        <div class="thumbnail">
            <img src="img/uiz7.jpg" th:src="'/img/img'+${checkedCourse.getCourseId()}+'.jpg'"
                 alt="通用的占位符缩略图">
            <div class="caption" th:id="${checkedCourse.getCourseId()}">
                <h3><a class="video" href="#" th:href="'/video/video'+${checkedCourse.getCourseId()}+'.mp4'" th:text="${checkedCourse.getCourseName()}">缩略图标签</a></h3>
                <p th:text="${checkedCourse.getSpecialty()}">一些示例文本。一些示例文本。</p>
                <button type="button" class="btn btn-primary deleteCourse" value="deleteCourse">删除视频</button>
                <label th:text="'播放量:'+${checkedCourse.getClickCount()}">播放量</label>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/webjars/jquery/3.4.1/jquery.js}"></script>
<script>
    $(".deleteCourse").click(function () {
        var courseId = $(this).parent().attr("id");
        $.ajax({
            type:"POST",
            url:"/deleteCourse",
            data:{
                "courseId":courseId
            },
            dataType:"json",
            success:function (result) {
                location.reload();
                if(result.success === true){
                    alert("删除成功");
                }else alert("删除失败");
            },
            error:function () {
                alert("删除失败");
            }
        })
    })
</script>
</body>
</html>